package com.xcw.bos.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xcw.bos.dao.IDecidedZoneDao;
import com.xcw.bos.dao.ISubareaDao;
import com.xcw.bos.domain.DecidedZone;
import com.xcw.bos.domain.Subarea;
import com.xcw.bos.page.PageBean;
import com.xcw.bos.service.IDecidedZoneService;

@Service
@Transactional
public class DecidedZoneServiceImpl implements IDecidedZoneService {

	@Resource
	private IDecidedZoneDao decidedZoneDao;
	@Resource
	private ISubareaDao subareaDao;
	@Override
	public void pageQuery(PageBean<DecidedZone> pageBean) {
		decidedZoneDao.pageQuery(pageBean);

	}

	@Override
	public void save(DecidedZone model, String[] subareaids) {
		decidedZoneDao.save(model);//持久对象
		if(subareaids != null && subareaids.length > 0){
			for(String subareaid : subareaids){
				Subarea subarea = subareaDao.findById(subareaid);//持久对象
				subarea.setDecidedZone(model);//持久对象关联，事务提交时自动更新数据
			}
		}

	}

}
